package com.itheima.controller;

import com.itheima.common.Result;
import com.itheima.dto.ConfigDTO;
import com.itheima.dto.updateDTO;
import com.itheima.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/sys_config")
@RestController
@Slf4j
public class ConfigController {
    private final ConfigService configService;

    public ConfigController(ConfigService configService) {
        this.configService = configService;
    }

    @GetMapping("/all")
    public Result<?> getAll() {
        log.info("getAll执行了");
        ConfigDTO config = configService.getAll();
        return Result.success(config);
    }

    @PostMapping("/update")
    public Result<?> update(@RequestBody List<updateDTO> updateDTO) {
        configService.update(updateDTO);
        return Result.success();
    }
}
